Rails.application.routes.draw do
  # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
  root 'welcome#index'

  get "test/user", to: "home#test_user"
  get "rugged", to: 'home#study_rugged'

  namespace :api do
    namespace :v1 do
      resources :users, only: [:index, :create, :show, :update, :destroy]
      resources :sessions, only: [:create]

      # 设置一个前缀
      scope path: '/user/:user_id' do
        resources :microposts, only: [:index]
      end
    end

    namespace :v2 do
      resources :users, only: [:index, :create, :show, :update, :destroy]
      resources :sessions, only: [:create]

      scope path: '/user/:user_id' do
        resources :microposts, only: [:index]
      end
    end
  end

  # 定义V1版本
  # scope '/api/v1' do
  #   # home控制器相关
  #   scope '/home' do
  #     post '/login', to: 'home#login'
  #   end
  #
  #   # 定义其他相关
  #   scope '/login' do
  #     post '/login', to: 'home#login'
  #   end
  # end
end
